# Maintainer: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
pkgname=tidyhtml
_pkgreal=tidy-html5
pkgver=5.8.0
pkgrel=1
pkgdesc="Tool to tidy down your HTML code to a clean style"
arch=all
url="https://www.html-tidy.org"
license="W3C"
makedepends="cmake libxslt"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev $pkgname-libs"
source="tidyhtml-$pkgver.tar.gz::https://github.com/htacg/tidy-html5/archive/$pkgver.tar.gz"
builddir="$srcdir"/$_pkgreal-$pkgver

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DSUPPORT_LOCALIZATIONS=OFF \
		-DTIDY_CONSOLE_SHARED=ON \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	./tidy --help > /dev/null
}

libs() {
	default_libs
	# symlink is not picked by abuild
	amove usr/lib/libtidy.so.*
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
f352165bdda5d1fca7bba3365560b64d6f70a4e010821cd246cde43bed5c23cea3408d461d3f889110fd35ec9b68aa2b4e95412b07775eb852b7ee1745007a44  tidyhtml-5.8.0.tar.gz
"
